﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using PowerCreator.LMS.Web.Project;
using System.Collections.Generic;

public partial class Theme_3_MyStudyProject : PowerCreator.LMS.Web.Base.WebBasePage
{
    ProjectStudent opProjectStudent = new ProjectStudent();
    ProjectUser opProjectUser = new ProjectUser();
    NewProjectPlan opProjectPlan = new NewProjectPlan();
    Project opProject = new Project();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    protected string ClassID = "0";

    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = config.GetLanagerValueByKey("theme_menu_Study", PowerCreator.LMS.Language.LanagetItemType.Page);
        this.Title += "----" + config.GetLanagerValueByKey("theme_Study_MyProjects", PowerCreator.LMS.Language.LanagetItemType.Page);

        if (!IsPostBack)
        {
            ClassID = Request.QueryString["ClassID"].ToString();
            //string search = GetSearch();
            //BinderPager(search);
            //BinderRPT(search, 1);
        }
    }
    protected override void InitPage()
    {
        //btn_Search.Text = config.GetLanagerValueByKey("btn_Search", PowerCreator.LMS.Language.LanagetItemType.Page);

        base.InitPage();
    }


    //private string GetSearch()
    //{
    //    StringBuilder sbSearch = new StringBuilder();

    //    if (Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO] == null)
    //    {
    //        sbSearch.Append("1 = 2 and ");
    //        Lab_Err.Text = "<br />您尚未登陆，当前位置需要登陆后才能使用，请您转到首页登陆！<br /> 点击<a href='Default.aspx'>这里</a>登陆！";
    //        Lab_Err.Visible = true;

    //    }
    //    else
    //    {
    //        PowerCreator.LMS.Web.User.LoginEntity login = (PowerCreator.LMS.Web.User.LoginEntity)Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO];
    //        sbSearch.Append(string.Format(" UserID={0} and ", login.UserID));
    //    } 

    //    if (!string.IsNullOrEmpty(txt_ProjectName.Text))
    //    {
    //        sbSearch.Append(string.Format(" TrainproName like '%{0}%' and ",txt_ProjectName.Text));
    //    }
    //    if (!string.IsNullOrEmpty(txt_ClassName.Text))
    //    {
    //        sbSearch.Append(string.Format(" ClassName like '%{0}%' and ", txt_ClassName.Text));
    //    }
    //    sbSearch.Append(" TrainclaSatate = 1");
    //    return sbSearch.ToString();
    //}

    //private void BinderPager(string search)
    //{
    //    AspNetPager1.PageSize = PowerCreator.LMS.Web.Config.WebConfig.PageSize;
    //    AspNetPager1.RecordCount = opProjectStudent.QueryVMSYSProjectUserCount(search);
    //}
    //private void BinderRPT(string search, int pageIndex)
    //{
    //    List<UserProjectClassInfo> list = new List<UserProjectClassInfo>();

    //    list = opProjectStudent.QueryVMSYSProjectUser(search, PowerCreator.LMS.Web.Config.WebConfig.PageSize, pageIndex);
    //    rpt_TrainProject.DataSource = list;
    //    rpt_TrainProject.DataBind();

    //    bool bldog = PowerCreator.LMS.SCR.Dog.CheckDog();

    //    for (int i = 0; i < rpt_TrainProject.Items.Count; i++)
    //    {
    //        if (!bldog)
    //        {
    //            if (i != 0)
    //            {
    //                rpt_TrainProject.Items[i].Visible = false;
    //                AspNetPager1.Visible = false;
    //            }
    //        }
    //        Label lbl_StudentState = (Label)rpt_TrainProject.Items[i].FindControl("lbl_StudentState");
    //        if (lbl_StudentState.Text.ToLower() == "false")
    //        {
    //            LinkButton lnkbtn_study = (LinkButton)rpt_TrainProject.Items[i].FindControl("lnkbtn_study");
    //            lnkbtn_study.Enabled = false;
    //        }
    //    }
    //}


    //protected void btn_Search_Click(object sender, EventArgs e)
    //{
    //    string search = GetSearch();
    //    BinderPager(search);
    //    BinderRPT(search, 1);
    //}

    //protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    //{
    //    string search = GetSearch();
    //    BinderRPT(search, AspNetPager1.CurrentPageIndex);
    //}
    //protected void rpt_TrainProject_ItemCommand(object source, RepeaterCommandEventArgs e)
    //{
    //    if (e.CommandName.ToString() == "lstudy")
    //    {
    //        NewProjectPlanInfo info = new NewProjectPlanInfo();
    //        PowerCreator.LMS.Project.Entity.VOTTrainClass voProjectClass = opProjectUser.LoadProjectClass(int.Parse(e.CommandArgument.ToString()));
    //        PowerCreator.LMS.Project.Entity.VOTTrainProject voProject = opProject.LoadTrainProject(voProjectClass.FKTrainclaTrainproID);
    //        Label lbl_rpt_msg = (Label)e.Item.FindControl("lbl_rpt_msg");
    //        if (voProject.TrainproSatate != 1)
    //        {
    //            if (voProject.TrainproSatate == 0)
    //                lbl_rpt_msg.Text = "方案己被冻结!";
    //            else if (voProject.TrainproSatate == 2)
    //                lbl_rpt_msg.Text = "方案正在审核中!";
    //            return;
    //        }

    //        info.ProjectID = voProjectClass.FKTrainclaTrainproID;
    //        if (Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO] == null)
    //        {
    //            lbl_rpt_msg.Text = "未登录或登录超时!请重新登录!";
    //            return;
    //        }
    //        PowerCreator.LMS.Web.User.LoginEntity login = (PowerCreator.LMS.Web.User.LoginEntity)Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO];
    //        info.UserID = login.UserID;
    //        if (voProjectClass.TrainclaID == int.MinValue)
    //            info.ClassID = 0;
    //        else
    //            info.ClassID = voProjectClass.TrainclaID;
    //        opProjectPlan.AddProjectPlan(info);

    //        string url = "MyStudyProject.aspx?ClassID=" + e.CommandArgument.ToString();
    //        PowerCreator.LMS.Common.Script.Script.RedirectURL(url);
    //    }
    //}
}
